import CryptoJS from 'crypto-js'

const key = '1234567812345678'

/**
 * 加密
 *
*/
export function aesEncrypto(val) {
	let keys = CryptoJS.enc.Utf8.parse(key);
	let encryptoData = CryptoJS.AES.encrypt(val, keys, {
		iv:key,
		mode:CryptoJS.mode.ECB,
		pad: CryptoJS.pad.Pkcs7
	});
	
	return encryptoData.toString();
}

/**
 * 解密
 *
*/
export function aesDecrypto(val) {
	let keys = CryptoJS.enc.Utf8.parse(key);
	let decryptoData = CryptoJS.AES.decrypt(val, keys, {
		iv:key,
		mode:CryptoJS.mode.ECB,
		pad: CryptoJS.pad.Pkcs7
	})
	
	return decryptoData.toString(CryptoJS.enc.Utf8);
}
